package com.icehelper.hades.base.util;

import java.util.HashMap;
import java.util.Map;

public class MapBuilder<K, V> {

  private Map<K, V> map;

  protected MapBuilder() {
    map = new HashMap<>();
  }

  public MapBuilder<K, V> add(K key, V value) {
    this.map.put(key, value);
    return this;
  }

  public Map<K, V> build() {
    return map;
  }

  public static <KEY, VALUE> MapBuilder<KEY, VALUE> create(KEY key, VALUE value) {
    return new MapBuilder<KEY, VALUE>().add(key, value);
  }

  public static <KEY, VALUE> Map<KEY, VALUE> single(KEY key, VALUE value) {
    return create(key, value).build();
  }

}